package com.itheima.features.catc;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * 使用jdk1.9所提供的try...catch新的语法完成io流资源的自动释放
 */
public class TryCatchDemo02 {

    public static void main(String[] args) {

        try(
                FileInputStream fileInputStream = new FileInputStream("") ;
                FileOutputStream fileOutputStream = new FileOutputStream("") ;

         ) {

            // 一次取读取一个字节数组进行文件的复制
            byte[] bytes = new byte[1024] ;
            int len = -1 ;
            while((len = fileInputStream.read(bytes)) != -1) {
                fileOutputStream.write(bytes , 0 , len);
            }

        }catch (Exception e) {
            e.printStackTrace();
        }


    }

}
